<?php
require_once ('../classes/gcmEASClass.php');
$deviceId =  isset($_REQUEST['enrollTxt']) ? $_REQUEST['enrollTxt']:'device Id not set';
$controlVar = isset($_REQUEST['controlVar']) ?$_REQUEST['controlVar']:'controlVar not set';


if($controlVar == '1') {
   startRegisteringDevicewithDB($deviceId);
} else if($controlVar == '2') {
   sendDataToDeviceViaGCM();
} else if($controlVar == '3') {
   emptyRegistrationIDTable();
}

function startRegisteringDeviceWithDB($deviceId) {
	$gcmObject = new GCMEAS();
	$result = $gcmObject -> registerDeviceAtServer($deviceId,'3');
	if($result['deviceregistered'] == '1') {
		echo json_encode($result);
	}
}
function sendDataToDeviceViaGCM() {
	$gcmObject = new GCMEAS();
	$result = $gcmObject -> sendMessageToDevice(3);
	echo json_encode($result);
}
function emptyRegistrationIDTable() {
	$gcmObject = new GCMEAS();
	$result = $gcmObject -> emtpyTableRegistrationId();
	echo json_encode($result);
}

?>